//
//  WSRegistViewController.m
//  GroupFourFM
//
//  Created by dllo on 16/1/4.
//  Copyright © 2016年 GroupFour. All rights reserved.
//

#import "WSRegistViewController.h"
#import "WSRegistView.h"

@interface WSRegistViewController ()<WSRegistViewDelegate>{
    
    WSProgressHUD *hud;
}

@end

@implementation WSRegistViewController
- (void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
    [self.tabBarController.tabBar setHidden:YES];
}

-(void)viewWillDisappear:(BOOL)animated{
    
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.hidden = NO;
    [self.tabBarController.tabBar setHidden:NO];

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    WSRegistView *registView = [[WSRegistView alloc] init];
    [self.view addSubview:registView];
    registView.delegate = self;
    [registView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.mas_equalTo(@0);
    }];
    
}

- (void)backViewController {

    [self.navigationController popViewControllerAnimated:YES];
}

-(void)registWithPassWord:(NSString *)passWord repassWord:(NSString *)repassWord iphone:(NSString *)iphone userName:(NSString *)userName{
    
    NSString *body = [NSString stringWithFormat:@"action=user_reg&user_name=%@&pwd=%@&pwd2=%@&token=%@",userName,passWord,repassWord,iphone];
    [WH_AppTools postUrl:URLstr body:body result:HXJSON requestStyle:HXRequestString headerFile:nil success:^(id result) {
        NSDictionary *dic = result;
        NSString *status = [dic objectForKey:@"status"];
        NSString *message = [dic objectForKey:@"message"];
        if ([status isEqualToString:@"success"]){
            
            NSLog(@"注册---%@",result);
            [WSProgressHUD showImage:nil status:@"注册成功"];
            [self backViewController];
            [MobClick event:@"Regist"];
            
        }else{
            
            [WSProgressHUD showImage:nil status:message];
            
        }
        
    } failure:^(NSError *error) {
        
        
    }];
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
